﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ArtClub.DBAL;
using ArtClub.Controller;

namespace ArtClub
{
    public partial class ShowProductDescription : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                PieceCtr control = new PieceCtr();
                Piece prod = control.getPiece(Convert.ToInt32(Request.QueryString["id"]));
                if (prod != null)
                {
                    lblName.Text = "Name: " + prod.name;
                    lblArtist.Text = "Artist: " + prod.artist;
                    lblType.Text = "Type: " + prod.type;
                    lblDescription.Text = "Description:\n " + prod.description;
                    imgProduct.ImageUrl = prod.image;
                }
            }
            else
            {
                Response.Redirect("BrowseCatalogue.aspx");
            }
        }

        protected void ButtonUpdate_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                PieceCtr control = new PieceCtr();
                Piece prod = control.getPiece(Convert.ToInt32(Request.QueryString["id"]));
                Response.Redirect("UpdateCatalogue.aspx?id="+prod.id);
            }
        }

        protected void btnCreateAuction_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                PieceCtr pCtr = new PieceCtr();
                Piece p = pCtr.getPiece(Convert.ToInt32(Request.QueryString["id"]));
                Response.Redirect("AddAuction.aspx?id=" + p.id);

            }
        }
    }
}
        
